package com.ll.mybatis.dao;


import com.ll.mybatis.entity.Employee;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author 刘龙
 * @version 1.0
 */

public interface EmployeeMapper {
    /**
     * 查询
     *
     * @param id
     * @return
     */
    public Employee getEmployeeById(Integer id);


    /**
     * 查询,条件是多个个条件
     *
     * @param id
     * @param lastName
     * @return
     */
    public Employee getEmployeeByIdAndLastNmae(@Param("id") Integer id, @Param("lastName") String lastName);

    /**
     * 查询,条件是多个个条件
     *
     * @param map
     * @return
     */
    public Employee getEmployeeByMap(Map<String, Object> map);

    /**
     * 查询,条件是多个个条件 涉及${}
     *
     * @param map
     * @return
     */
    public Employee getEmployeeByMap2(Map<String, Object> map);

    /**
     * 注解方式
     *
     * @param id
     * @return
     */
    @Select("SELECT id, last_name,gender,email FROM tbl_emoloyee WHERE id=#{id}")
    public Employee getEmployeeBYIdAnnottion(Integer id);

    /**
     * 查询 返回集合
     *
     * @param lastName
     * @return
     */
    public List<Employee> getEmpsByLastNameLike(String lastName);

    /**
     * 通过部门id查找对应的员工
     * @param departmentId
     * @return
     */
    public List<Employee> getEmployeeByDepartmentId(Integer departmentId);

    /**
     * 返回一条map,key是列名, 值就是对应的值
     * @param id
     * @return
     */
    public Map<String, Object> getEmpByIdReturnMap(Integer id);

    /**
     * 查询.多条记录封装一个map, Key就是id, 值是javaBean
     * @MapKey("id"): 通知mybatis封装这个map的时候使用哪个属性作为map的主键
     */
    @MapKey("id")
    public Map<Integer, Employee> getEmpsByLastNameLikeReturnMap(String lastName);

    /**
     * 添加
     *
     * @param employee
     */
    public void addEmp(Employee employee);

    /**
     * 修改
     *
     * @param employee
     */
    public void updateEmp(Employee employee);

    /**
     * 删除
     *
     * @param id
     */
    public int deleteEmpById(Integer id);

    /**
     * 测试多参数传递,参数是集合
     */
    public List<Employee> getEmpByList(List list);

    /**
     * 测试多参数传递,参数是数组
     */
    public List<Employee> getEmpByArray(Object[] objects);
}
